#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include<vector>
using namespace std;
vector<int> nums;
int getmin(int end)
{
    if (end == 1 || end == 0)
        return nums[end];
    else return nums[end] + min(getmin(end - 1), getmin(end - 2));
}
int main()
{
    int n = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        nums.push_back(x);
    }
    int min1 = min(getmin(n - 1), getmin(n - 2));
    cout << min1;
}